﻿using System;
using System.Diagnostics;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using MvcContrib.StructureMap;
using NCommon.Data;
using NCommon.Storage;
using Roommate.Infrastructure.IoC;
using StructureMap;

namespace Roommate.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );




        }
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            Bootstrapper.Restart();

            //Set current Controller factory as StructureMapControllerFactory
            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());

            Debug.WriteLine(ObjectFactory.WhatDoIHave());

        }

        //protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
      
        //{
        //    HttpContext.Current.Request.
        //    if (System.Web.HttpContext.Current.Session != null)
        //    Store.Session.Set("TRANSACTION", "test");

        //}

    }
}